'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc., All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH USB_GET_CURRENT_FRAME_NUMBER 9F "Jul 25, 2004"
.SH NAME
usb_get_current_frame_number \- Return current logical usb frame number
.SH SYNOPSIS
.nf
#include <sys/usb/usba.h>



\fBusb_frame_number_t\fR \fBusb_get_current_frame_number\fR(\fBdev_info_t *\fR\fIdip\fR);
.fi

.SH INTERFACE LEVEL
illumos DDI specific (illumos DDI)
.SH PARAMETERS
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 7n
Pointer to the device's \fBdev_info\fR structure.
.RE

.SH DESCRIPTION
The \fBusb_get_current_frame_number()\fR function retrieves the current logical
USB frame number.
.sp
.LP
Isochronous requests can be started on a particular numbered frame. An offset
number of frames (typically between 4 and 10) can be added to the current
logical frame number to specify the number of an upcoming frame to start an
isochronous request.
.sp
.LP
The USB specification requires that the frame frequency (the period between
start-of-frame packets) is one millisecond.  The illumos operating environment
USB implementation uses a running counter of the number of milliseconds since
boot as the current logical frame number.
.SH RETURN VALUES
On success, the \fBusb_get_current_frame_number()\fR function returns the
current USB frame number. On failure it returns \fB0\fR. The function fails if
\fIdip\fR is NULL.
.SH CONTEXT
May be called from user, kernel or interrupt context.
.SH EXAMPLES
.in +2
.nf
    usb_pipe_handle_t handle;
    usb_frame_number_t offset = 10;
    usb_isoc_req_t *isoc_req;

    isoc_req = usb_alloc_isoc_req(...);
      ...
      ...
    isoc_req->isoc_frame_no = usb_get_current_frame_number(dip) + offset;
    isoc_req->isoc_attributes = USB_ATTRS_ISOC_START_FRAME;
      ...
      ...
    if (usb_pipe_isoc_xfer(handle, isoc_req, 0) != USB_SUCCESS) {
      ...
    }
.fi
.in -2

.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Architecture	PCI-based systems
_
Interface stability	Committed
.TE

.SH SEE ALSO
.BR attributes (7),
.BR usb_alloc_isoc_req (9F),
.BR usb_get_max_pkts_per_isoc_request (9F),
.BR usb_pipe_get_max_bulk_transfer_size (9F),
.BR usb_pipe_isoc_xfer (9F),
.BR usb_isoc_request (9S)
